package com.nchu.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;

import java.sql.Timestamp;

@Repository
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Filter {
    private int minMoney;
    private int maxMoney;
    private String amountRestrictions;
    private String typeRestrictions;
    private String deadlineRestrictions;
    private Timestamp timeInterval;
    public void setTimeInterval() {
        if (this.deadlineRestrictions == null){
            this.timeInterval = new Timestamp((0));
        }
        else {
            switch (this.deadlineRestrictions) {
                case "10分钟以上":
                    this.timeInterval = new Timestamp((10 * 60 * 1000));
                    System.out.println("10分钟以上");
                    break;
                case "20分钟以上":
                    this.timeInterval = new Timestamp((20 * 60 * 1000));
                    System.out.println("20分钟以上");
                    break;
                case "30分钟以上":
                    this.timeInterval = new Timestamp((30 * 60 * 1000));
                    System.out.println("30分钟以上");
                    break;
                case "40分钟以上":
                    this.timeInterval = new Timestamp((40 * 60 * 1000));
                    System.out.println("40分钟以上");
                    break;
                case "50分钟以上":
                    this.timeInterval = new Timestamp((50 * 60 * 1000));
                    System.out.println("50分钟以上");
                    break;
                case "60分钟以上":
                    this.timeInterval = new Timestamp((60 * 60 * 1000));
                    break;
                default:
                    this.timeInterval = new Timestamp((0));
                    break;
            }
        }
    }
    public void setMoney(){
        if (this.amountRestrictions == null){
            this.minMoney = 0;
            this.maxMoney = Integer.MAX_VALUE;
        }
        else {
            switch (this.amountRestrictions){
                case "0-1元":
                    this.minMoney = 0;
                    this.maxMoney = 1;
                    break;
                case "2-3元":
                    this.minMoney = 2;
                    this.maxMoney = 3;
                    break;
                case "4-5元":
                    this.minMoney = 4;
                    this.maxMoney = 5;
                    break;
                case "6-7元":
                    this.minMoney = 6;
                    this.maxMoney = 7;
                    break;
                case "7元以上":
                    this.minMoney = 7;
                    this.maxMoney = Integer.MAX_VALUE;
                    break;
                default:
                    this.minMoney = 0;
                    this.maxMoney = Integer.MAX_VALUE;
                    break;
            }
        }

    }

}